package other.clone;


import java.util.ArrayList;
import java.util.List;

/**
 * @author hubb
 * @Date 2019/3/28 23:46
 */
public class TestClone {
    public static void main(String[] args) throws CloneNotSupportedException {
        List<CloneObject> CloneObjects1 = new ArrayList<CloneObject>();
        List<CloneObject> CloneObjects2 = new ArrayList<CloneObject>();
        CloneObject clone1 = new CloneObject();
        clone1.setId("1");
        clone1.setName("张三");
        CloneObjects1.add(clone1);
        CloneObject clone2 = new CloneObject();
        clone2.setId("2");
        clone2.setName("李四");
        CloneObjects1.add(clone2);

        for(CloneObject CloneObject : CloneObjects1) {
            CloneObjects2.add(CloneObject.clone());
        }

        clone1.setName("张三1");
        for(CloneObject CloneObject : CloneObjects1) {
            System.out.println(CloneObject.getName());
        }

        for(CloneObject CloneObject : CloneObjects2) {
            System.out.println(CloneObject.getName());
        }

    }
}
